Skip to content

fix(k8s): preserve service network fields on redeploy - #4013

Open
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/preserve-service-network-fields
Open

fix(k8s): preserve service network fields on redeploy#4013
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/preserve-service-network-fields

Conversation

@Elvand-Lie

@Elvand-Lie Elvand-Lie commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Changes

The raw Kubernetes deployer reconstructs a corev1.Service when redeploying a function. On updates, it previously preserved only the existing Service's ResourceVersion.

Because the generated Service does not contain the network configuration allocated by Kubernetes, redeploying an existing function could submit an empty spec.clusterIP and fail with:

Service "<function-name>" is invalid: spec.clusterIP: Invalid value: "": field is immutable

This change preserves the existing Service's ClusterIP, ClusterIPs, IPFamilies, and IPFamilyPolicy before calling Update, while continuing to generate mutable fields such as ports, selectors, labels, and annotations from the function configuration.

New Service creation is unchanged, so Kubernetes continues to allocate and default its network fields.

The KEDA deployer inherits the fix because it delegates workload deployment to the raw Kubernetes deployer.

Regression tests cover IPv4 single-stack, IPv6 single-stack, dual-stack, preservation of generated mutable fields, and the initial Service creation path.

Testing

  • Tests done and verified locally: unit test suites (make test), linting and repository checks (make check), and test coverage for single-stack IPv4/IPv6 and dual-stack Service network field preservation.
  • Manual redeployment with func deploy --deployer=raw verified against a Kubernetes cluster, confirming existing Service ClusterIP and network configuration are preserved across updates.
  • Fork CI passed the repository's precheck, unit, integration, template, Podman, and runtime E2E suites.

/kind bug

Release Note

Fixed raw and KEDA function redeployments failing when updating an existing Kubernetes Service.

Docs

NONE

@knative-prow knative-prow Bot added the kind/bug Bugs label Aug 18, 2026
@knative-prow

knative-prow Bot commented Aug 18, 2026